import { ApiProperty } from '@nestjs/swagger';
import { Decorator_DtoIsNumber_Base } from '@/common/decorators/dtoIsNumber';
import { IsArray, IsNotEmpty, IsOptional, IsString } from 'class-validator';

export class Product_Create_Dto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '规格名称' })
  productName: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ type: 'text', description: '规格说明' })
  productAtention: string;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ example: 9.5, type: 'float', description: '规格价格' })
  productPrice: number;

  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '规格图片' })
  productImg: string;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ type: 'bigint', description: '时长' })
  productTime: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '位数' })
  productNum: number;

  @IsArray()
  @IsNotEmpty()
  @ApiProperty({ description: '规格属性ID' })
  specs: number[];

  @IsArray()
  @IsNotEmpty()
  @ApiProperty({ description: '规格属性类型ID' })
  specsType: number[];

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '商品ID' })
  platformId: number;
}

export class Product_Find_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  size?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  page?: number;

  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '平台ID' })
  platformId?: number;
}

export class Product_FindAll_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsOptional()
  @ApiProperty({ description: '平台ID' })
  platformId: number;
}

export class Product_Update_Dto {
  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  id: number;

  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '规格名称' })
  productName: string;

  @IsString()
  @IsNotEmpty()
  @ApiProperty({ description: '规格图片' })
  productImg: string;

  @IsString()
  @IsOptional()
  @ApiProperty({ description: '规格说明' })
  productAtention?: string;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ example: 9.5, type: 'float', description: '规格价格' })
  productPrice: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ type: 'bigint', description: '时长' })
  productTime: number;

  @Decorator_DtoIsNumber_Base()
  @IsNotEmpty()
  @ApiProperty({ description: '位数' })
  productNum: number;
}
